package member.action;

import java.util.Map;

import member.dao.MemberDao;
import member.dto.MemberDto;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class LogonAction extends ActionSupport {
	
		private String id;
		private String password;
		private String name;
		


	public String execute() throws Exception {
		
		int check = MemberDao.userCheck(id, password);
		
		if(check==1){
			ActionContext context = ActionContext.getContext();
			@SuppressWarnings("unchecked")
			Map<Object, Object>session = (Map<Object, Object>) context.getSession();
			MemberDto userdata = new MemberDto();
			userdata = MemberDao.userAllData(id);
			session.put("id", id);
			session.put("password", password);
			session.put("name", userdata.getName());
			context.setSession(session);
			
			return "success";
						
		}else{
			
			return "err";
		}
	}
		
	public String getId(){
		return id;
	}
	public String getPassword(){
		return password;
	}
	public String getName(){
		return name;
	}
	public void setId(String id){
		this.id=id;
	}
	public void setPassword(String password){
		this.password=password;
	}
	public void setName(String name){
		this.name=name;
	}

}